package com.wise.wing.views;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;

public class SimpleListView extends LinearLayout {
	
	protected Context mContext;
	private BaseAdapter adapter;
	
	public SimpleListView(Context context) {
		this(context, null);
	}
	
	public SimpleListView(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public SimpleListView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		mContext = context;
		init();
	}
	
	private void init() {
		setOrientation(VERTICAL);
	}
	
	public void setAdapter(BaseAdapter adapter) {
		this.adapter = adapter;
		setData();
	}
	
	private void setData() {
		removeAllViews();
		for (int i = 0; i < adapter.getCount(); i++) {
			addView(adapter.getView(i, null, this));
		}
	}

}
